package com.yanqu.road.logic.activity.foxcard.game.effect;

import com.yanqu.road.entity.activity.foxcard.FoxBaseCard;
import com.yanqu.road.entity.activity.foxcard.FoxHandCard;
import com.yanqu.road.logic.activity.foxcard.game.FoxCardGameLogic;
import com.yanqu.road.logic.activity.foxcard.game.eFoxCardShowType;
import com.yanqu.road.logic.activity.foxcard.game.eFoxCardTriggerType;

import java.util.Collections;
import java.util.List;

/**
 * 整局战斗，每触发指定属性牌，可以提升效果
 * 指定增强牌|加筹码基础值|乘筹码基础值|加倍率基础值|乘倍率基础值|金币基础值
 */
public class FoxCardEffect10 extends FoxCardEffectBase {
    @Override
    protected void effectHandle(FoxCardGameLogic gameLogic, FoxHandCard handCard) {
        int buffId = Integer.valueOf(effectConfig.getParamsList().get(0));
        if ((triggerType == eFoxCardTriggerType.BUFF_TRIGGER && handCard != null)) {
            if (handCard.getReinforceEffect() == buffId) {
                gameLogic.newFoxShow(eFoxCardShowType.EFFECT_CARD_LV_UP.getValue()).setSettleCards(Collections.singletonList(effectCard)).setShowValue(1);
            }
        } else if (triggerType == eFoxCardTriggerType.AFTER_SCORE) {

            int totalTimes = gameLogic.getGameData().getHistoryBuffTimesMap().getOrDefault(buffId, 0);

            int addBaseScore = Integer.valueOf(effectConfig.getParamsList().get(1)) + totalTimes * Integer.valueOf(effectConfig.getUpgradeParamsList().get(0));
            int addBaseScoreMulti = Integer.valueOf(effectConfig.getParamsList().get(2)) + totalTimes * Integer.valueOf(effectConfig.getUpgradeParamsList().get(1));
            int addBaseMulti = Integer.valueOf(effectConfig.getParamsList().get(3)) + totalTimes * Integer.valueOf(effectConfig.getUpgradeParamsList().get(2));
            int addBaseMultiMulti = Integer.valueOf(effectConfig.getParamsList().get(4)) + totalTimes * Integer.valueOf(effectConfig.getUpgradeParamsList().get(3));
            int goldChange = Integer.valueOf(effectConfig.getParamsList().get(5)) + totalTimes * Integer.valueOf(effectConfig.getUpgradeParamsList().get(4));

            List<FoxBaseCard> foxEffectCards = Collections.singletonList(effectCard);
            gameLogic.addBaseScore(addBaseScore, foxEffectCards, null); //加基础筹码
            gameLogic.addBaseScoreMulti(addBaseScoreMulti, foxEffectCards, null); //当前基础筹码乘算
            gameLogic.addBaseMulti(addBaseMulti, foxEffectCards, null); //加基础倍率
            gameLogic.addBaseMultiMulti(addBaseMultiMulti, foxEffectCards, null); //当前基础倍率乘算
            gameLogic.goldChange(goldChange, foxEffectCards, null, triggerType); //加金币
        }

    }
}
